package com.example.service.impl;

import com.example.common.Page;
import com.example.common.PageQueryParam;
import com.example.dao.TSongListMapper;
import com.example.entity.TSongListEntity;
import com.example.service.TSongListService;
import com.example.vo.SingListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("tSongListService")
public class TSongListServiceImpl implements TSongListService {

    @Autowired
    TSongListMapper tSongListMapper;

    @Override
    public void create(TSongListEntity tSongListEntity) {
        tSongListMapper.create(tSongListEntity);
    }

    @Override
    public Page<SingListVo> query(PageQueryParam<TSongListEntity> pageQueryParam) {
        Page<SingListVo> page = new Page<>();
        Integer total =  tSongListMapper.selectCount(pageQueryParam.getParam());
        List<SingListVo> singListVos = tSongListMapper.selectAll(pageQueryParam);
        page.setRows(singListVos);
        page.setTotal(total);
        return page;
    }

    @Override
    public Integer delete(TSongListEntity tSongListEntity) {
        return tSongListMapper.delete(tSongListEntity.getId());
    }
}